<?php

namespace App\Http\Controllers\User;

use App\Http\Controllers\Controller;
use App\Models\CashDraw;
use Illuminate\Http\Request;

class CashDrawsController extends Controller
{
    public function __construct()
    {
        $this->middleware('auth:user');
    }

    public function index(Request $request)
    {
        $cashInfo = $request->user('user')->cashInfo;
        if (is_null($cashInfo)) {
            return redirect()->route('user.cashinfos.index')->with('error', '请完成提现信息');
        }

        $builder = CashDraw::query()->where('user_id', $request->user('user')->id);



        $logs = $builder->latest()->paginate(10);
        return view('user.cash_draws.index', compact('logs'));
    }
}
